package edu.servlet;

import edu.dao.HeroDAO;
import edu.entity.Hero;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


public class EditHeroServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
		String id = arg0.getParameter("id");
		int idForSearch = Integer.parseInt(id);
		Hero hero = HeroDAO.getHero(idForSearch);
		
		arg0.setAttribute("hero", hero);
		
		arg0.getRequestDispatcher("editHero.jsp").forward(arg0, arg1);
	}

}
